//
//  Collect.swift
//  MyCookbook
//
//  Created by liaokylin on 2024/10/14.
//

import SwiftUI

struct Collect: View {

    @State private var currentSelect:Int = 1
    let tabs:[TabItemValue] = [
        TabItemValue(id: 1, text: "全部"),
        TabItemValue(id: 2, text: "菜单"),
        TabItemValue(id: 3, text: "课程"),
        TabItemValue(id: 4, text: "浏览历史"),
    ]
    
    var body: some View {
        VStack{
            Tabs(currentSelect: $currentSelect, tabsItems: tabs)
            TabView(selection:$currentSelect){
                ForEach(tabs){ tab in
                    switch currentSelect {
                    case 1:
                        All().tag(tab.id)
                    case 2:
                        Menu().tag(tab.id)
                    case 3:
                        Course().tag(tab.id)
                    case 4:
                        BrowsingHistory().tag(tab.id)
                    default:
                        EmptyView()
                    }
                }
            }.tabViewStyle(.page(indexDisplayMode: .never))
        }.frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/,maxHeight: .infinity)
    }
}

#Preview {
    Collect()
}
